package com.file;

import java.io.File;

/**
 * @author Xiongx
 * @version 1.0
 * @date 2021/5/26 14:23
 * @since JDK 1.8
 */
public class FileUtils {

    public static void main(String[] args) {
        String path=getSystemFilePath();
        fileList(path);
    }

    public static void fileList(String file){
        File file1=new File(file);
        if(file1.isDirectory()){
            String[] strings=file1.list();
            for (int i = 0; i <strings.length ; i++) {
                System.out.println(strings[i]);
                fileList(file+File.separator+strings[i]);
            }
        }
    }



    //通过文件夹名称获取File
    public static File getFileByName(String basePath,String name){
        return new File(basePath+File.separator+name);
    }

    //获取路径列表文件夹
    public static String[] getSystemFileList(File file){
        return file.list();
    }

    //获取系统路径
    public static File getSystemFile(){
        String path=getSystemFilePath();
        return getFileByString(path);
    }

    public static File getFileByString(String string){
        return new File(string);
    }

    public static String getSystemFilePath(){
        return System.getProperty("user.dir");
    }
}
